<template>
  <div>
     <el-radio-group v-model="secondVal" @change="radioChange">
     <el-row>
      <el-col :span="24">
        <el-radio :value="1">
            秒,允许的通配符[*, - /]
         
         </el-radio>
      </el-col>
      <el-col :span="24">
        <el-radio :value="2">
          周期 从 <el-input-number v-model="toStart"></el-input-number>到
            <el-input-number v-model="toEnd"></el-input-number>
        </el-radio>
       
      </el-col>
      <el-col>
        <el-radio :value="3">
           从 <el-input-number v-model="formStart"></el-input-number>秒开始，每
            <el-input-number v-model="interval"></el-input-number>
            秒执行一次
        </el-radio>
      </el-col>
      <el-col>
        <el-radio :value="4">
          <el-select style="width:300px;" multiple v-model="selCon">
             <el-option  :value="1">1</el-option>
             <el-option  :value="2">2</el-option>
             <el-option  :value="3">3</el-option>
             <el-option  :value="4">4</el-option>
             <el-option  :value="5">5</el-option>
          </el-select>
        </el-radio>
      </el-col>
     </el-row>
  
     </el-radio-group>
  </div>
</template>
<script setup>
import {ref,defineEmits,watch} from 'vue'
let emits=defineEmits(['sendSecond'])

     let secondVal=ref(1)
  // 从多少到多少秒
     let toStart=ref(0)
     let toEnd=ref(0)
    //     从多少秒开始，每多少秒执行一次
     let formStart=ref(0)
     let interval=ref(0)
   //  // 选中秒
     let selCon=ref([])

    //  
 watch(toStart,()=>{
  secondVal.value=2;
  secondCron.value=toStart.value+"-"+toEnd.value
  emits("sendSecond",secondCron.value)
 })
 watch(toEnd,()=>{
  secondVal.value=2;
  secondCron.value=toStart.value+"-"+toEnd.value
  emits("sendSecond",secondCron.value)
 })
 watch(formStart,()=>{
  secondVal.value=3;
  secondCron.value=formStart.value+"/"+interval.value
  emits("sendSecond",secondCron.value)
 })
 watch(interval,()=>{
  secondVal.value=3;
  secondCron.value=formStart.value+"/"+interval.value
  emits("sendSecond",secondCron.value)
 })
 watch(selCon,()=>{
  secondVal.value=4;
  secondCron.value=selCon.value.join(',')
  emits("sendSecond",secondCron.value)
 })
    // 
    let secondCron=ref('*')
     let radioChange=(val)=>{
          // 子传父 把生成的表达式传给父组件
          console.log(val,"------")
          if(val===1){
            secondCron.value="*"
          }
          if(val===2){
             secondCron.value=toStart.value+"-"+toEnd.value
          }
          if(val===3){
            secondCron.value=formStart.value+"/"+interval.value
          }
          if(val===4){
            secondCron.value=selCon.value.join(',')
          }
          emits("sendSecond",secondCron.value)
     }

</script>